package org.peerjs;

import org.peerjs.configuration.PeerOptions;
import org.peerjs.log.PLog;
import org.peerjs.log.PLogFactory;
import org.peerjs.message.PeerJsMessage;
import org.peerjs.rtc.AbstractRtcPeerConnection;
import org.peerjs.rtc.IRtcPeerConnectionFactory;
import org.peerjs.rtc.ISignalling;

final class PeerCallFactory {
    private static final PLog log = PLogFactory.getLogger(PeerCallFactory.class);
    IRtcPeerConnectionFactory rtcConnectionFactory;

    final PeerCall createCallableCall(PeerOptions peerOptions,
                                      ISignalling signalSender) {
        AbstractRtcPeerConnection rtcPeerConnection = rtcConnectionFactory.create(peerOptions);
        return new PeerCall(peerOptions, rtcPeerConnection, signalSender) {
        };
    }

    final AnswerablePeerCall createAnswerableCall(PeerOptions peerOptions, PeerJsMessage offerMessage,
                                                  ISignalling signalSender) {
        AbstractRtcPeerConnection rtcPeerConnection = rtcConnectionFactory.create(peerOptions);
        return new AnswerablePeerCall(peerOptions, offerMessage, rtcPeerConnection, signalSender);
    }
}
